package tongcheng.com.tongcheng.base.main.activity;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.readystatesoftware.systembartint.SystemBarTintManager;

import butterknife.Bind;
import butterknife.ButterKnife;
import tongcheng.com.tongcheng.ConStans;
import tongcheng.com.tongcheng.R;
import tongcheng.com.tongcheng.base.BaseActivity;
import tongcheng.com.tongcheng.network.CallServer;
import tongcheng.com.tongcheng.network.MyRequest;
import tongcheng.com.tongcheng.network.OnCallBack;
import tongcheng.com.tongcheng.utils.Setting;

public class WoDeQianBaoActivity extends BaseActivity {
    @Bind(R.id.back)
    ImageView mBack;
    @Bind(R.id.title)
    TextView mTitle;
    @Bind(R.id.title_bar)
    RelativeLayout mBg;
    @Bind(R.id.qianbao_ll1)
    LinearLayout mQianbaoLl1;
    @Bind(R.id.qianbao_ll2)
    LinearLayout mQianbaoLl2;
    @Bind(R.id.person_ll2)
    RelativeLayout mPersonLl2;
    @Bind(R.id.qianbao_tixian)
    TextView mQianbaoTixian;
    @Bind(R.id.qianbao_chongzhi)
    TextView mQianbaoChongzhi;
    @Bind(R.id.qianbao_rc)
    RecyclerView mQianbaoRc;
    @Bind(R.id.qianbao_money)
    TextView mQianbaoMoney;
    @Bind(R.id.back_text)
    TextView mBackText;
    @Bind(R.id.title_line)
    View mTitleLine;

    @Override
    public Integer initResid() {

        return R.layout.activity_wo_de_qian_bao;
    }

    @Override
    public void initCreate(Bundle savedInstanceState) {
        settitlebar(mBg);
        SystemBarTintManager tintManager = getTintManager();
        mBack.setImageResource(R.mipmap.fanhui_geren);
        mBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        mTitleLine.setVisibility(View.GONE);
        mBg.setBackgroundColor(Color.TRANSPARENT);
        mTitle.setTextColor(Color.WHITE);
        mTitle.setText("我的钱包");


        mQianbaoMoney.setText(Setting.getYuE() + "");//取余额

        //设置状态栏为透明色
        if (tintManager != null) {
            tintManager.setStatusBarTintResource(R.color.title_barno);
        }


        //提现
        mQianbaoTixian.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startactivity(WoDeQianBaoActivity.this, TiXianActivity.class);
            }
        });


        //充值
        mQianbaoChongzhi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startactivity(WoDeQianBaoActivity.this, ChongZhiActivity.class);
            }
        });


        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        mQianbaoRc.setLayoutManager(linearLayoutManager);


        /*mQianbaoRc.setAdapter();*/
    }


    @Override
    protected void onResume() {
        super.onResume();
        mQianbaoMoney.setText(Setting.getYuE() + "");//取余额
        initBankData();
    }

    //初始化银行卡数据
    private void initBankData() {
        MyRequest request = new MyRequest(ConStans.BankCardList_Url);
        request.add("id", Setting.getId());
        CallServer.getInstance().addPost(this,request, 1, new OnCallBack() {
            @Override
            public void OnSuccess(int what, String json, Object ject) {

            }
        });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
